import request from "@/services/interceptors";
import { ProDescriptions } from "@ant-design/pro-components";
import type { ProDescriptionsActionType } from "@ant-design/pro-components";
import { useRef } from "react";

interface TeacherDetailProps {
  teacherId: number;
}
const TeacherDetail = ({ teacherId }: TeacherDetailProps) => {
  const actionRef = useRef<ProDescriptionsActionType>(null);
  return (
    <ProDescriptions
      actionRef={actionRef}
      request={async () => {
        const res = await request.sgks.teacherGetList({ teacherId });
        return res;
      }}
      column={1}
      columns={[
        {
          title: "教师ID",
          dataIndex: "teacherId",
        },
        {
          title: "教师用户名",
          dataIndex: "userName",
        },
        {
          title: "教师姓名",
          dataIndex: "realName",
        },
        {
          title: "所教课程",
          dataIndex: "courses",
          renderText: (courses) => {
            return courses?.map((course: any) => course.courseName)?.join("、");
          },
        },
        {
          title: "所教专业",
          dataIndex: "majors",
          renderText: (majors) => {
            return majors?.map((major: any) => major.majorName)?.join("、");
          },
        },
        {
          title: "所教班级",
          dataIndex: "classes",
          renderText: (classes) => {
            return classes
              ?.map(
                (item) =>
                  `${item.classGrade}年级${item.classTeam}队${item.classUnit}区队`
              )
              ?.join("、");
          },
        },
      ]}
    ></ProDescriptions>
  );
};
export default TeacherDetail;
